package com.yanqu.road.server.cmd.beautyescort;


import com.yanqu.road.entity.enums.eItemId;
import com.yanqu.road.entity.enums.eLogMoneyType;
import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.player.CurrencyModule;
import com.yanqu.road.server.gameplayer.module.player.PreReduceModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;
import com.yanqu.road.utils.property.PropertyHelper;

@Cmd(code = Protocol.S_BEAUTY_ESCORT_SEARCH_USER_FROM_CROSS, desc = "查探")
public class BeautyEscortSearchCmdFromCross extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        BeautyEscortProto.BeautyEscortSearchUserRespMsg respMsg = BeautyEscortProto.BeautyEscortSearchUserRespMsg.parseFrom(packet.getBytes());

        //消耗
        String searchCost = eItemId.BEAUTY_ESCORT_MAGNIFIER.getValue() + "=" + 1;
        player.getModule(PreReduceModule.class).restorePreReduce(searchCost);

        if(respMsg.getRet() == 0){
            //扣除
            player.getModule(CurrencyModule.class).removeCurrency(PropertyHelper.parseStringToProperty(searchCost), eLogMoneyType.BeautyEscort, eLogMoneyType.BeautyEscortSearchConsume);
        }
        player.sendPacket(Protocol.U_BEAUTY_ESCORT_SEARCH_USER, respMsg.toBuilder());
    }

    @Override
    public void sendData(GamePlayer player) {

    }
}
